package com.backend.vse.ws;


import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Random;

@Data
@Accessors(chain = true)
public class AIseller {
    private int MaxPrice;
    private int MinPrice;
    private String purchase;
    private int buyerPrice;
    private double alterPrice;
//111
    public void setAlterPrice(double alterPrice) {
        this.alterPrice = alterPrice;
    }

    public int getMinPrice() {
        return MinPrice;
    }

    public String getSituation() {
        return situation;
    }

    public int getMaxPrice() {
        return MaxPrice;
    }

    private String situation;
    public AIseller(){

        String[] options = {"车况好", "车况差"};
        Random random = new Random();
        int randomIndex = random.nextInt(options.length);
        int min, max, min1, max1;

        this.situation = options[randomIndex];
        if (situation.equals("车况好")) {
            min = 80000;
            max = 90000;
            min1 = 70000;
            max1 = 80000;
        } else { // "车况差"
            min = 75000;
            max = 80000;
            min1 = 70000;
            max1 = 75000;
        }

        this.MaxPrice = generateRandomPrice(min, max, random);
        this.MinPrice = generateRandomPrice(min1, max1, random);
    }

    private int generateRandomPrice(int min, int max, Random random)
    {
        if (max > min) {
            return random.nextInt(max - min + 1) + min;
        } else {
            throw new IllegalArgumentException("Max value must be greater than Min value");
        }
    }

}
